package com.magicsoft.share.presenter.share;

import com.magicsoft.share.base.BasePresenter;
import com.magicsoft.share.bean.share.Special;
import com.magicsoft.share.constant.APIService;
import com.magicsoft.share.rx_retrofit_network.location.retrofit.RetrofitUtil;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.NetWorkTransformer;
import com.magicsoft.share.rx_retrofit_network.location.rxandroid.SimpleObserver;
import com.magicsoft.share.view.share.ISpecialListView;

import java.util.List;

import io.reactivex.annotations.NonNull;

/**
 * Created by lyf on 2017/11/29/029.
 */

public class SpecialListPresenter extends BasePresenter<ISpecialListView> {
    public void articleSpecialList(int articleTypeId) {
        RetrofitUtil.getApi(APIService.class)
                .articleSpecialList(articleTypeId)
                .compose(new NetWorkTransformer<List<Special>>())
                //   .compose(new LoadingTransformer<List<Special>>(mContext))
                .subscribe(new SimpleObserver<List<Special>>(mCompositeDisposable) {
                    @Override
                    public void call(@NonNull List<Special> specials) {

                        if (null != getView()) {
                            getView().specialListSuccess(specials);
                        }
                    }
                });
    }
}
